package com.cherish.pattern.prototype.deep;

/**
 * @Classname TestClone
 * @Date 2019/4/7 13:33
 * @Author admin
 * @Description TODO
 */
public class TestClone {

    public static void main(String[] args) throws Throwable {
        //孙悟空  源对象
        SunWuKong sunWuKong = new SunWuKong();
        System.out.println("孙悟空:" + sunWuKong);
        System.out.println("孙悟空-金箍棒:" + sunWuKong.getJinGuBang());
        System.out.println("孙悟空-Date:" + sunWuKong.getDate());

        //孙行者 浅克隆
        SunWuKong sunxingzhe = sunWuKong.shallowClone(sunWuKong);
        System.out.println("孙行者:" + sunxingzhe);
        System.out.println("孙悟空=孙行者:" + (sunWuKong == sunxingzhe));
        System.out.println("孙悟空=孙行者-金箍棒:" + (sunWuKong.getJinGuBang() == sunxingzhe.getJinGuBang()));
        System.out.println("孙悟空=孙行者-Date:" + (sunWuKong.getDate() == sunxingzhe.getDate()));
//者行孙 深克隆
        SunWuKong zhexingsun = sunWuKong.deepClone(sunWuKong);
        System.out.println("者行孙:" + zhexingsun);
        System.out.println("孙悟空=者行孙:" + (sunWuKong == zhexingsun));
        System.out.println("孙悟空=者行孙-金箍棒:" + (sunWuKong.getJinGuBang() == zhexingsun.getJinGuBang()));
        System.out.println("孙悟空=者行孙-Date:" + (sunWuKong.getDate() == zhexingsun.getDate()));
        //行者孙 Object clone
        SunWuKong xingzhesun = (SunWuKong) sunWuKong.clone();
        System.out.println("行者孙:" + xingzhesun);
        System.out.println("孙悟空=行者孙:" + (sunWuKong == xingzhesun));
        System.out.println("孙悟空=行者孙-金箍棒:" + (sunWuKong.getJinGuBang() == xingzhesun.getJinGuBang()));
        System.out.println("孙悟空=行者孙-Date:" + (sunWuKong.getDate() == xingzhesun.getDate()));

    }

}
